/*
 * @Description: 
 * @Author: xiongkuobiao
 * @Date: 2023-02-28 11:09:31
 * @LastEditors: xiongkuobiao
 * @LastEditTime: 2023-05-11 10:23:38
 */
// function myNew(fn, ...args) {
//   let obj = Object.create(fn.prototype)
//   let res = fn.apply(obj, args)
//   return typeof res == 'object' ? res : obj
// }

function myNew(fn, ...args) {
  let obj = Object.create(fn.prototype);
  let res = fn.apply(obj, args);
  if (typeof res == "object") {
    return res;
  } else {
    return obj;
  }
}

function fn1(...args) {
  console.log(111, args);
  this.aaa = 111;
  return 111;
}
let a = myNew(fn1, 1213);
console.log(a);

// let a = new fn1(12, 2323)
// console.dir(a.aaa);
